<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="../ExtJS/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="../ExtJS/ext-all.js"></script>
		<script type="text/javascript">
			Ext.onReady(function() {	
				var aa = '<table>' 
							+ '<tbody>'
							+ '<tr>'
								+ '<td width="80">编号</td>'
								+ '<td width="100">姓名</td>'
								+ '<td width="100">年龄</td>'
								+ '<td width="100">部门</td>'
							+ '</tr>'
							+ '<tpl for="depts">'
							+ '<tpl for="users">'
							+ '<tpl if="parent.name.length $gt; 3">'
								+ '<tr>'
									+ '<td>{#}</td>'
									+ '<td>{name}</td>'
									+ '<td>{age}</td>'
									+ '<td>{parent.name}</td>'
								+ '</tr>'
							+'</tpl>'
							+'</tpl>'
							+ '</tpl>'
							+ '</tbody>'
						+ '</table>';
						
				var data = {
						name:'江中集团', 
						depts:[
							{name: '技术部', users:[{name: 'AA', age: 29, sex:1},{name: 'AA', age: 29, sex:1}]},       
							{name: '技术部22', users:[{name: 'AA', age: 29, sex:1},{name: 'AA', age: 29, sex:1}]}
						]
				};
				
				var formatName = function(v,vs) {
					var ch = vs['sex']==1?'先生':'小姐';
					return v.slice(0,1)+ch;
				}
				
				var tpl = new Ext.Template(aa);
				tpl.formatName = formatName;
				tpl.append(document.body, data);		
			});
		</script>
	</head>
	<body>
	</body>
</html>
